package me.softwareengineer.guice.rendering.domain;

import java.util.List;
import java.util.Map;

import me.softwareengineer.guice.rendering.listener.EndTableRowEvent;
import me.softwareengineer.guice.rendering.listener.Listener;
import me.softwareengineer.guice.rendering.listener.StartTableRowEvent;

/**
 * Represents a row in a table element
 * 
 * @author yad.tahir
 * 
 * @see TableElement
 * @see TableCellElement
 * @see TableHeadCellElement <pre>
 * This class is thread-safe and can be cached/re-used and used concurrently.
 * </pre>
 */
public class TableRowElement extends Element {

	/**
	 * Creates a table row.
	 * 
	 * @param children
	 *            the sub elements of the row. Check {@link HasProperties} for
	 *            more info.
	 * @param properties
	 *            the properties of the row. Check {@link HasProperties} for
	 *            more info.
	 */
	public TableRowElement(List<Element> children,
			Map<String, String> properties) {
		super(children, properties);
	}

	/**
	 * {@inheritDoc}
	 * 
	 */
	@Override
	public void afterElement(Listener listener) {
		EndTableRowEvent e = new EndTableRowEvent(getAllProperties());
		listener.onEvent(e);
	}

	/**
	 * {@inheritDoc}
	 * 
	 */
	@Override
	public void beforeElement(Listener listener) {
		StartTableRowEvent e = new StartTableRowEvent(getAllProperties());
		listener.onEvent(e);
	}
}
